﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using bdxyit.com.RecruitmentAppSys.IDAL;
using bdxyit.com.RecruitmentAppSys.DALFactory;
using bdxyit.com.RecruitmentAppSys.Models;
using bdxyit.com.RecruitmentAppSys.ViewModels;
namespace bdxyit.com.RecruitmentAppSys.BLL
{
    public class CandidatePositionsViewModelBLL
    {

        public static CandidatePositionsViewModels InitCandidatePositionsView(string userId)
        {
            CandidatePositionsViewModels cpvm = new CandidatePositionsViewModels();
            List<ApplyJobAction> aja = ApplyJobActionBLL.GetAllApplyJobActionByUserId(userId);
            switch (aja.Count)
            {
                case 1:
                    cpvm.ApplyJobActionFirst = aja[0];
                    break;
                case 2:
                    cpvm.ApplyJobActionFirst = aja[0];
                    cpvm.ApplyJobActionSecond = aja[1];
                    break;
                case 3:
                    cpvm.ApplyJobActionFirst = aja[0];
                    cpvm.ApplyJobActionSecond = aja[1];
                    cpvm.ApplyJobActionThird = aja[2];
                    break;
                default:
                    cpvm.ApplyJobActionFirst = new ApplyJobAction();
                    cpvm.ApplyJobActionFirst.UserID = userId;
                    cpvm.ApplyJobActionSecond = new ApplyJobAction();
                    cpvm.ApplyJobActionSecond.UserID = userId;
                    cpvm.ApplyJobActionThird = new ApplyJobAction();
                    cpvm.ApplyJobActionThird.UserID = userId;
                    break;
            }
            cpvm.CompanyInfo = CompanyInfoBLL.GetCompanyInfo();
            cpvm.CompanyPost = CompanyPostBLL.GetCompanyPost();
            return cpvm;
        }

        public static CandidatePositionsViewModels EditCandidatePositions(string userId)
        {
            CandidatePositionsViewModels cpvm = new CandidatePositionsViewModels();
            List<ApplyJobAction> aja = ApplyJobActionBLL.GetAllApplyJobActionByUserId(userId);
            switch (aja.Count)
            {
                case 1:
                    cpvm.ApplyJobActionFirst = aja[0];
                    break;
                case 2:
                    cpvm.ApplyJobActionFirst = aja[0];
                    cpvm.ApplyJobActionSecond = aja[1];
                    break;
                case 3:
                    cpvm.ApplyJobActionFirst = aja[0];
                    cpvm.ApplyJobActionSecond = aja[1];
                    cpvm.ApplyJobActionThird = aja[2];
                    break;
                default:
                    cpvm.ApplyJobActionFirst = new ApplyJobAction();
                    cpvm.ApplyJobActionFirst.UserID = userId;
                    cpvm.ApplyJobActionSecond = new ApplyJobAction();
                    cpvm.ApplyJobActionSecond.UserID = userId;
                    cpvm.ApplyJobActionThird = new ApplyJobAction();
                    cpvm.ApplyJobActionThird.UserID = userId;
                    break;
            }
            cpvm.CompanyInfo = CompanyInfoBLL.GetCompanyInfo();
            cpvm.CompanyPost = CompanyPostBLL.GetCompanyPost();
            return cpvm;
        }

        public static CandidatePositionsViewModels DetailsCandidatePositions(string userId)
        {
            CandidatePositionsViewModels cpvm = new CandidatePositionsViewModels();
            List<ApplyJobAction> aja = ApplyJobActionBLL.GetAllApplyJobActionByUserId(userId);
            switch (aja.Count)
            {
                case 1:
                    cpvm.ApplyJobActionFirst = aja[0];
                    break;
                case 2:
                    cpvm.ApplyJobActionFirst = aja[0];
                    cpvm.ApplyJobActionSecond = aja[1];
                    break;
                case 3:
                    cpvm.ApplyJobActionFirst = aja[0];
                    cpvm.ApplyJobActionSecond = aja[1];
                    cpvm.ApplyJobActionThird = aja[2];
                    break;
                default:
                    cpvm.ApplyJobActionFirst = new ApplyJobAction();
                    cpvm.ApplyJobActionFirst.UserID = userId;
                    cpvm.ApplyJobActionSecond = new ApplyJobAction();
                    cpvm.ApplyJobActionSecond.UserID = userId;
                    cpvm.ApplyJobActionThird = new ApplyJobAction();
                    cpvm.ApplyJobActionThird.UserID = userId;
                    break;
            }
            cpvm.CompanyInfo = CompanyInfoBLL.GetCompanyInfo();
            cpvm.CompanyPost = CompanyPostBLL.GetCompanyPost();
            return cpvm;
        }
    }
}
